﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

public partial class Admin_MembershipProvider_Access_AddUser : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {

        }
    }
    private void Page_PreRender()
    {
        UserRoles.DataSource = System.Web.Security.Roles.GetAllRoles();
        UserRoles.DataBind();



    }
    protected void AddUser1()
    {
        // Add User.
        MembershipUser newUser = Membership.CreateUser(username.Text, password.Text, email.Text);
        newUser.Comment = comment.Text;
        Membership.UpdateUser(newUser);

        // Add Roles.
        foreach (ListItem rolebox in UserRoles.Items)
        {
            if (rolebox.Selected)
            {
                System.Web.Security.Roles.AddUserToRole(username.Text, rolebox.Text);
            }
        }


        //Customer Details




    }

    protected void btnAddUser_Click(object sender, EventArgs e)
    {
        try
        {
            AddUser1();

            Response.Redirect("users.aspx");
        }
        catch (Exception ex)
        {
            ConfirmationMessage.InnerText = "Insert Failure: " + ex.Message;
        }
    }

    protected void checkBoxCustomer_CheckedChanged(object sender, EventArgs e)
    {

    }
}
